﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Shapes;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Controls;

namespace MigratorUI.RenderEngine
{
    public class BroadCastAnimation : Animation
    {

        public BroadCastAnimation(Sprite sprite, bool isRepeatAnimation)
            : base(sprite,isRepeatAnimation)
        {
        }

        protected override System.Windows.Media.Geometry DefiningGeometry
        {
            get {return this.ellipse;}
        }
        
        private void BroadCastAnimationCompleted(object sender, EventArgs e)
        {
            base.AnimationCompleted();
        }

        protected override void CreateShape()
        {
            this.ellipse = new EllipseGeometry();
            this.ellipse.Center = new System.Windows.Point(Sprite.Position.X + (Sprite.Image.Width / 2), Sprite.Position.Y + (Sprite.Image.Height / 2));
            this.ellipse.RadiusX = 50;
            this.ellipse.RadiusY = 50;

            //Fill and Opacity
            //this.Fill = Brushes.Cyan;
            this.Opacity = 0.50;
            //this.OpacityMask = Brushes.Red;

            //Stroke
            this.Stroke = Brushes.Black;
            this.StrokeThickness = 2;
        }

        public override void RunAnimation()
        {
            DoubleAnimation animation = new DoubleAnimation();
            animation.From = 50;
            animation.To = 100;
            animation.Duration = new Duration(TimeSpan.FromSeconds(1));
            animation.Completed += new EventHandler(BroadCastAnimationCompleted);
            this.ellipse.BeginAnimation(EllipseGeometry.RadiusXProperty, animation);
            this.ellipse.BeginAnimation(EllipseGeometry.RadiusYProperty, animation);
            
         
        }


        private EllipseGeometry ellipse;
    }
}
